This invention relates to the field of computer systems. More particularly, an apparatus and methods are provided for handling events received at a server socket that may be shared among multiple client connections.
A computer system creates and uses sockets to handle communications with other computer systems. Some systems, such as servers, are configured to establish a large number of sockets because of the number of other computer systems (e.g., clients) with which it must communicate. A computer server may even set up and dedicate multiple sockets for each client system that it communicates with, because each socket may be configured with limited functionality, such as to handle only one type of connection, handle only one communication protocol, dispatch only one type of task, etc.
For example, in a server configured to stream QuickTime media to clients, one server socket may be allocated to each client media stream to handle control functions (e.g., using RTSP (Real-Time Streaming Protocol)), another socket for transmitting the media to the client (e.g., according to RTP (Real-Time Transport Protocol)), and yet another to receive status information from the client (e.g., through RTCP (Real-Time Transport Control Protocol)).
However, such systems have limited scalability, because as the number of clients grows, the number of sockets that the server must maintain grows commensurately. And, because each socket is typically allocated its own share of processor resources (e.g., in the form of a dedicated thread), the resulting contention for processor time places an upper bound on the number of sockets or clients that the server can service. Because of the large number of processes, threads, daemons or other entities demanding processor time on behalf of individual sockets or media streams, the server spends an inordinate amount of time performing context switches. And other, non-media tasks, may be denied necessary resources.
Other systems attempt to avoid this contention and lack of scalability by allocating one processor thread or period of processor time among all sockets handling client communications, or among all sockets handling a particular type or form of client communication. However, as the number of media streams and sockets grows, there is the danger that insufficient resources will be allotted to a given socket or stream (particularly a real-time media stream).